﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace Utility
{
    public class NotifyIcon
    {
        public System.Windows.Forms.NotifyIcon Icon { get; private set; }

        public NotifyIcon(ContextMenu contextMenu, string iconPath, UriKind uriKind = UriKind.Relative)
        {
            Icon = new System.Windows.Forms.NotifyIcon()
            {
                Text = Process.GetCurrentProcess().ProcessName,
                Icon = new Icon(System.Windows.Application.GetResourceStream(new Uri("/" + iconPath, uriKind)).Stream),
                Visible = true,
                ContextMenu = contextMenu
            };
        }

        public void Close()
        {
            Icon.Visible = false;
            Icon = null;
        }
    }
}
